package cn.zhz.service;

import cn.zhz.dao.DistrictDao;
import cn.zhz.pojo.District;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;

public class DistrictService {
    private DistrictDao dao = new DistrictDao();

    public void addDistrict(District district) {
        Transaction tx = null;
        try {
            tx = dao.currentSession().beginTransaction();
            dao.save(district);
            tx.commit();
        } catch (HibernateException e) {
            e.printStackTrace();
            if (tx != null) {
                tx.rollback();
            }
        }
    }
    public District findDistrictById(Integer id) {
        return this.dao.selectDistrictById(id);
    }
}
